package com.twang.stock.controller.old;

import com.twang.stock.service.jinyan.StockFinanceReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping(value = "/financeReport")
@Slf4j
public class StockFinanceReportController {
    @Autowired
    private StockFinanceReportService stockFinanceReportService;

    /**
     * 生成财报
     *
     * @return
     * @throws Exception
     */
    @GetMapping(value = "/getZhangDie")
    @ResponseBody
    public void getZhangDie(String code){
        for(int i=0;i<=6;i++){
            if(i==0){
                stockFinanceReportService.excuteRepaotquery(1,"2020","2020-03-31","一季报",1);
            }
            if(i==1){
                stockFinanceReportService.excuteRepaotquery(1,"2020","2020-06-30","中报",2);
            }
            if(i==2){
                stockFinanceReportService.excuteRepaotquery(1,"2020","2020-09-30","三季报",3);
            }
            if(i==3){
                stockFinanceReportService.excuteRepaotquery(1,"2020","2020-12-31","年报",4);
            }
            if(i==4){
                stockFinanceReportService.excuteRepaotquery(1,"2021","2021-03-31","一季报",1);
            }
            if(i==5){
                stockFinanceReportService.excuteRepaotquery(1,"2021","2021-06-30","中报",2);
            }
            if(i==6){
                stockFinanceReportService.excuteRepaotquery(1,"2021","2021-09-30","三季报",3);
            }
        }
        //setQueterJll("");
    }

//    /**
//     * 计算净利润环比增长率:
//     *  http://127.0.0.1:8080/financeReport/setQueterJll?code=sz000516
//     * @return
//     * @throws Exception
//     */
//    @GetMapping(value = "/setQueterJll")
//    @ResponseBody
//    public void setQueterJll(String code){
//        for(int i=0;i<=1;i++){
//            if(i==0){
//                stockFinanceReportService.setJlrHbzzl("2020",code);
//            }
//            if(i==1){
//                stockFinanceReportService.setJlrHbzzl("2021",code);
//            }
//        }
//    }

    /**
     * http://127.0.0.1:8080/financeReport/excuteRepaotqueryByCode?code=sz000516&name=国际医学
     * @param code
     */
    @GetMapping(value = "/excuteRepaotqueryByCode")
    @ResponseBody
    public void excuteRepaotqueryByCode(String code,String name){
                stockFinanceReportService.excuteRepaotqueryByCode(code,name);
    }

}
